package com.itheima.d01_threadpool_runnable;

import java.util.List;
import java.util.concurrent.*;

public class Test {
    public static void main(String[] args) {
        ExecutorService pool = new ThreadPoolExecutor(
                2,
                5,
                3,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy ()
        );
        pool.execute(() -> {
            System.out.println("服务员1，正在工作");
        });
        try{
            Thread.sleep(1000);
        }
        catch(InterruptedException e){
            throw new RuntimeException(e);
        }
        //一般不建议关闭线程池
        List<Runnable> runnables = pool.shutdownNow();
        System.out.println("暴力关闭未执行的任务："+runnables);
        System.out.println("主线程执行over");
    }

    }

